<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8"/>
    <title>列表</title>
    <link href="__STATIC__/component/pear/css/pear.css" rel="stylesheet"/>
    {include file='public/head.html'}
</head>
<body class="pear-container">

<div class="layui-card">
    <div class="layui-card-body">
        <div style="padding-left: 15px;">
            日志状态：
            <a href="javascript:;" data-menu-id="14" data-title="配置管理" data-url="{:url('config/index')}" class="btn-addtabs">
            {if site('is_log',0)==1:}<span class="layui-badge layui-bg-green">开启</span>{else:}<span class="layui-badge layui-bg-danger">关闭</span>{/if}
            </a>
        </div>
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-delete="{:check_auth('clear')}"
               data-auth-detail="{:check_auth('detail')}"
        ></table>
    </div>
</div>

<script src="__STATIC__/component/layui/layui.js"></script>
<script src="__STATIC__/component/pear/pear.js"></script>
<script>
    layui.use(['aphpTable', 'aphp'], function () {
        let aphpTable = layui.aphpTable;
        let $ = layui.$;
        let aphp = layui.aphp;

        let init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            delete_url: "{:url('clear')}",
            detail_url: "{:url('detail')}",
        };

        aphpTable.render({
            init: init,
            search: true,
            quickSearch: 'username@like#搜索账户', // 快速搜索设置
            toolbar: ['refresh_table',
                [{
                    text: '删除一个月前',
                    url: init.delete_url + '?type=1',
                    method: 'request',
                    auth: 'delete',
                    confirm: '确认删除一个月前日志吗？',
                    icon: 'layui-icon layui-icon-time',
                    class: 'layui-btn layui-btn-warm layui-btn-sm',
                }],
                [{
                    text: '清空日志',
                    url: init.delete_url,
                    method: 'request',
                    auth: 'delete',
                    confirm: '确认清空日志吗？',
                    icon: 'layui-icon layui-icon-delete',
                    class: 'layui-btn layui-btn-danger layui-btn-sm',
                }]
            ],
            url: "{:url('index')}",
            cols: [
                [
                    { title: 'ID', field: 'id', align: 'center'},
                    { title: '账户', field: 'admin_name', sreachOp: 'like'},
                    { title: '操作', field: 'title', sreachOp: 'like'},
                    { title: '控制器', field: 'controller' },
                    { title: '方法', field: 'method' },
                    { title: 'IP', field: 'user_ip'},
                    { title: '时间', field: 'create_time' ,templet: aphpTable.formatter.datetime, search: 'range' },
                    { title: '操作', align: 'center', templet: aphpTable.formatter.tool, operat:  [
                            [{
                                title: '详情',
                                text: '详情',
                                url: init.detail_url,
                                auth: 'detail',
                                method: 'open',
                                icon: 'layui-icon layui-icon-search',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                            }]
                        ]
                    },
                ]
            ],
            page: {}
        });

        aphpTable.bindEvent();
    })
</script>
</body>
</html>